package saxion.speelveld.spaceengineer.controller;

import saxion.speelveld.spaceengineer.R;
import saxion.speelveld.spaceengineer.model.TradePlanet;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class tradePlanetsSimpleListAdapter extends ArrayAdapter<TradePlanet>
{

	Context context;

	TradePlanet[] planets;

	public tradePlanetsSimpleListAdapter(Context context, TradePlanet[] tradePlanets)
	{
		super(context, R.layout.trade_list_view_item, tradePlanets);
		this.context = context;
		this.planets = tradePlanets;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		convertView = inflater.inflate(R.layout.trade_list_view_item, parent, false);

		ImageView planetImage = (ImageView) convertView.findViewById(R.id.iv_planet_image);
		TextView planetName = (TextView) convertView.findViewById(R.id.tv_planet_tekst);

		planetImage.setImageResource(planets[position].getPlanetImage());
		planetName.setText(planets[position].getPlanetName());

		return convertView;
	}
}
